<?php
namespace app\admin\model;
use think\Model;
use think\model\concern\SoftDelete;

class Admin extends Model{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    //user展示
    public static function adminList()
    {
        return Admin::alias('a')
            ->join('auth au','a.author=au.id')
            ->field('a.id,a.name,a.headimg,a.author,au.aname')
            ->paginate(['list_rows'=>5]);
    }
    //user添加字段
    public static function adminAdd($file)
    {
        if (isset($file) && $file!=''){
            return Admin::create($file);
        }
    }
    //回收站的展示
    public static function userList()
    {
        return Admin::onlyTrashed()
            ->alias('a')
            ->join('auth au','a.author=au.id')
            ->field('a.id,a.name,a.headimg,a.author,au.aname')
            ->paginate(['list_rows'=>5]);
    }

    public static function userEdit($id)
    {
        return Admin::find($id);
    }
    //修改页的子u但
    public static function xiuUserEdit($where)
    {
       return Admin::update($where);
        
    }
    //user展示页的软删除
    public static function userListDel($id)
    {
        $list=Admin::find($id);
        $user=$list->delete();
        return $user;
    }
    //user回收站的真删
    public static function zhenUserDel($zhenId)
    {
        $user=Admin::onlyTrashed()->find($zhenId);
        $user=$user->force()->delete();
        return $user;
    }

    public static function huiUserDel($huiId)
    {
        $user=Admin::onlyTrashed()->find($huiId);
        $user=$user->restore();
        return $user;
    }
}